Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diggy mask debug surface bug #1039

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

SimonFlapse
Copy link
Member

@SimonFlapse SimonFlapse commented Feb 18, 2020

Prevents the print_grid_value function from producing an error when surface is nil or invalid.

The Mask debugging setting may, or may not work. I'm simply not sure what it is supposed to do.

closes #1037

Ideally we would have to make sure the mask debugging works, before merging this PR

Copy link
Contributor

@BlueRock2 BlueRock2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this change, but received an error that there was an attempt to index surface (nil value). No error if I check surface first then if not nil, check surface.valid. However, I think the code that displays the mask only executes once early on. So if the surface isn't ready yet, it never displays? I think the call to display the mask might still need to be relocated, but not sure where. In a temp fix I did, I displayed right after the first mined rock message for user pops up, but is there a way to call the function when the surface is ready and user first gains control?

@SimonFlapse
Copy link
Member Author

I tried this change, but received an error that there was an attempt to index surface (nil value). No error if I check surface first then if not nil, check surface.valid. However, I think the code that displays the mask only executes once early on. So if the surface isn't ready yet, it never displays? I think the call to display the mask might still need to be relocated, but not sure where. In a temp fix I did, I displayed right after the first mined rock message for user pops up, but is there a way to call the function when the surface is ready and user first gains control?

Weird. The new code snippet should return if the surface is nil, and only try to index the .valid field if the surface isn’t nil.

@BlueRock2
Copy link
Contributor

Still concerned that even with the surface check the code gets blocked the one time it tries to run. Curious Simon what you think about this: Within diggy_cave_collapse.lua the code that prints the mask is:

if (config.enable_mask_debug) then
        local surface = RS.get_surface()
        mask_disc_blur(
            0,
            0,
            10,
            function(x, y, fraction)
                Debug.print_grid_value(fraction, surface, {x = x, y = y})
            end
        )
    end

It is currently located in a function that does config registration and sets up events but think it is trying run before the diggy surface is setup. However, I also noticed that diggy_cave_collapse does have some code to check for the event, on_surface_created and a handler for it.
Event.add(defines.events.on_surface_created, on_surface_created)
and on_surface_created = function(event) Would it make sense to move mask debug code block within this function? If so, then I think before running it we also check to be sure index == 1.

@SimonFlapse SimonFlapse marked this pull request as draft April 29, 2020 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diggy debug grid print
2 participants